/**
 * @file   MiraPoint2DHom.h
 * @author Josep Sabater (jsabaterm@el.ub.edu)
 * @date   September, 2015
 * @version 1.0.0
 * @ingroup MiraGeometryLib
 * @brief Implementation of a 2D Point for Homogeneous operations.
 *
 *
 */

#include <cmath>
#include <algorithm>

#include "MiraPoint2DHom.h"
#include "MiraVector2D.h"

namespace MiraGeometryLib{
    
    Point2DHom::Point2DHom(const Vector2D &vec) : x_( vec.x() ), y_( vec.y() ), h_(1){}

    Point2DHom& Point2DHom::operator = (Point2DHom v) {
        swap(v);
        return *this;
    }

    bool Point2DHom::operator == (const Point2DHom& ph) const {
           return (x_==ph.x_ && y_==ph.y_ && h_==ph.h_);
       }
    bool Point2DHom::operator != (const Point2DHom& ph) const {
           return (x_!=ph.x_ || y_!=ph.y_ || h_!=ph.h_);
       }

    /** Non-member friend function for << operator
     */
    std::ostream& operator << (std::ostream& os, const Point2DHom& v){
        return os << "Point2DHom (" << v.x_ << "," << v.y_ << "," << v.h_ << ")";
    }

    void Point2DHom::swap(Point2DHom& v){
        std::swap(x_, v.x_);
        std::swap(y_, v.y_);
    }
}
